<?php
/**
 * Created by PhpStorm.
 * User: moquan
 * Date: 2018/6/20
 * Time: 18:18
 */

namespace app\admin\validate;


class UserVali extends BaseValidate {

    //定义验证规则
    protected $rule = [
        "admin_name" => "require|min:5|max:22",
        "password" => "min:6|max:22",
        "role_id" => "require|number",
        "real_name" => "require",
        "phone" => "require|min:11|max:11|number",
    ];

    //定义验证提示
    protected $message = [
        "admin_name.require" => "用户名称不能为空",
        "admin_name.unique" => "用户名称已存在",
        "admin_name.min" => "用户名称不能小于5位",
        "admin_name.max" => "用户名称不能大于22位",
        "password.require" => "密码不能为空",
        "password.min" => "密码不能小于5位",
        "password.max" => "密码不能大于22位",
        "role_id.require" => "角色不能为空",
        "role_id.number" => "角色为数字类型",
        "real_name.require" => "真实名称不能为空",
        "phone.require" => "手机号码不能为空",
        "phone.min" => "手机号码不能小于11位",
        "phone.max" => "手机号码不能大于11位",
        "phone.number" => "手机号码必须为0-9数字",
    ];

    //定义验证场景
    protected $scene = [
        //添加
        'add'  =>  ['admin_name'=>'require|min:5|max:22|unique:admin_user', 'password'=>'require' ],
        'edit'  =>  ['admin_name', 'password'],
        //登录
        'login'  =>  ['admin_name'=>"require|min", 'password'=>'require' ]
    ];

    // 自定义验证规则
    /*protected function checkName($value,$rule,$data)
    {
        return '名称错误';
    }*/
}